package han.chensing.latos;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.Screen;

import han.chensing.latos.game.GameScreen;
import han.chensing.latos.game.container.FakeShapeRenderer;
import han.chensing.latos.load.LoadScreen;
import han.chensing.latos.res.Res;

public class GdxGame extends Game {

	Screen loadScreen;
	Screen gameScreen;
	volatile boolean loading=true;

	@Override
	public void create () {
		V.shapeRenderer = new FakeShapeRenderer();
		V.shapeRenderer.getShapeRenderer().setAutoShapeType(true);
		setScreen(loadScreen=new LoadScreen());
		Res.getInstance().fakeLoadAll();

	}

	@Override
	public void render () {
		super.render();
		if (loading&&Res.getInstance().readLoadSingle()) {
			setScreen(gameScreen=new GameScreen());
			loadScreen.dispose();
			loading=false;
		}
	}
	
	@Override
	public void dispose () {
		super.dispose();
		loadScreen.dispose();
		gameScreen.dispose();
		Res.getInstance().disposeAll();
		V.running=false;
	}
}
